!{include file='common/iheader.htm'}
<div id="i_nav">
	<h3 class="page_title">WIKI框架编辑 - !{$dict.word}</h3>
	<a class="button" href="/manager.php?app=wiki">WIKI管理</a>
</div>
<div class="form_item">
	<strong>词条名称：</strong>
	<div><input class="text_input" type="text" name="word" value="!{$dict.word}"/></div>
	<p><input type="button" value="修改" class="button" id="word_set"/></p>
</div>
<hr>
!{foreach from=$dict.items item=content key=index}
<div class="form_item">
	<strong>目录名称：</strong>
	<div><input class="text_input" type="text" index="!{$index}" name="index" value="!{$index}"/></div>
	<p><input type="button" value="修改" class="button index_set"/></p>
</div>
!{foreachelse}
<div class="form_item">
	暂无目录！
</div>
!{/foreach}
<script>
	$(function(){
		$('#word_set').click(function(){
			var word = $('input[name="word"]').val();
			if(word == '!{$dict.word}'){
				alert("没有变化！");
				return;
			}
			$.post('/manager.php?app=wiki&act=set_word',{
				word : word,
				id : '!{$dict._id}'
			}, function(data){
				var json = eval('(' + data + ')');
				alert(json.info);
			});
		});
		
		$('.index_set').click(function(){
			var input = $(this).parents('.form_item').find('.text_input');
			var index = $(input).attr('index');
			var new_index = $(input).val();
			$.post('/manager.php?app=wiki&act=set_index',{
				index : index,
				new_index : new_index,
				id : '!{$dict._id}'
			}, function(data){
				var json = eval('(' + data + ')');
				alert(json.info);
				if(json.result){
					//更新里面的值
					$(input).attr('index', new_index);
				}
			});
		});
	});
</script>
!{include file='common/ifooter.htm'}